/* Hashtable data type
*
* by Twilight Suzuka + Kuchiki Rukia + Urahara Kisuke
* 
*
* This file is provided as is (no warranties).
*/
// Hashtables are a convoluted structure that is extremely memory and CPU effecient.
// Hashtables usually are faster than keytables, but CAN be slower. 
// Hashtable searching can be much slower than keytables.
// Hashtables are best used when extremely fast lookup time is needed above all else.

#if defined _array_hashtable_included
    #endinput
#endif
#define _array_hashtable_included

#include <array_const>

///* Master Edit Functions

// Creates a new hashtable
native hashtable_create()

// Destroys a created hashtable, and sets the pointer back to NULL. You MUST destroy all hashtable's you create.
native hashtable_destroy(&hashtable_id)

// Clears a hashtable without deleting it
native hashtable_clear(hashtable_id)

// If hashtable_id = 0, returns the hashtable master table, which can be manipulated as an array.
// Else, returns the hashtable's master table hashtable_id.
native hashtable_convert(hashtable_id=0)

// Saves/loads hashtables from file. hashtable_id must be to an already created hashtable.
native hashtable_save(hashtable_id,file[])
native hashtable_load(hashtable_id,file[])

///* Master Amount Functions

// Counts the amount of hashtables in the master table.
native hashtable_count(start = 0, stop = -1)

// Returns the nth hashtable in the master table, into ret_array. Return value is its master table hashtable_id.
native hashtable_bycount(nth, start = 0, &ret_array = 0)

///* Slave Amount Functions

// Returns how many indexes are in the hashtable
native hashtable_size(hashtable_id, start[] = "", stop[] = "~~~~~~~~~~~")

// Returns the nth index in the hashtable. 
// NOTE: Pass a variable to hold the index[], and its length, after success. 
// Length is 1 for bool/int/flo, 3 for vec, x for string.
native hashtable_get_nth(hashtable_id, nth, start[] = "",&success = 0,{Float,Sql,Result,_}:...)

///* Slave Edit Functions

// Returns the amount of memory this hashtable has used
native hashtable_memory(hashtable_id)

// Returns if index is used or not.
native hashtable_isfilled(hashtable_id, index[])
native hashtable_isempty(hashtable_id, index[])


///* Slave Set/Get/Delete Functions
// These don't need explaining.

// Gets the type of value stored in index. Uses pawn_type_* enum, see array_const for details.
native hashtable_get_type(id, index, disable_check = 0)

// Deletes an index from hashtable
native hashtable_delete(hashtable_id, index)

// set_type is from AP_* list in array_const
native hashtable_set(hashtable_id, index[], set_type,{Float,Sql,Result,_}:...)

// get format is [ret_val,len]. See array_const for details.
native hashtable_get(hashtable_id, index[], disable_check = 0,{Float,Sql,Result,_}:...)

native hashtable_set_bool(hashtable_id, index[], bool:set_bool)
native bool:hashtable_get_bool(hashtable_id, index[], disable_check = 0)

native hashtable_set_int(hashtable_id, index[], set_int)
native hashtable_get_int(hashtable_id, index[], disable_check = 0)

native hashtable_set_float(hashtable_id, index[], Float:set_flo)
native Float:hashtable_get_float(hashtable_id, index[], disable_check = 0)

native hashtable_set_string(hashtable_id, index[], set_str[])
native hashtable_get_string(hashtable_id, index[], val[], len, disable_check = 0)

native hashtable_set_vector(hashtable_id, index[], Float:set_vec[3])
native hashtable_get_vector(hashtable_id, index[], Float:val[3], disable_check = 0)

///* Slave Search Functions
// NOTE: Pass a variable to hold the index, and its length, after success. 
// Length is 1 for bool/int/flo, 3 for vec, x for string.
// If you do not wish to recieve the index, do not pass anything past success.

// Finds the first filled index starting at provhashtable_ided index, returns its key into ret[].
native hashtable_first(hashtable_id, index[], ret[], len, &success = 0,{Float,Sql,Result,_}:...)

// Finds the filled index after provhashtable_ided index, returns its key into ret[].
native hashtable_next(hashtable_id, index[], ret[], len, &success = 0,{Float,Sql,Result,_}:...)

// Finds the filled index before provhashtable_ided index, returns its key into ret[].
native hashtable_prev(hashtable_id, index[], ret[], len, &success = 0,{Float,Sql,Result,_}:...)

// Finds the last filled index starting at provhashtable_ided index, returns its key into ret[].
native hashtable_last(hashtable_id, index[], ret[], len, &success = 0,{Float,Sql,Result,_}:...)

#include <hashtable_stocks>